<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>图书管理页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="<%=basePath %>/static/js/jquery-3.3.1.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=basePath %>/static/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath %>/static/css/basic.css">
    <script src="<%=basePath %>/static/js/bootstrap.min.js"></script>
    <style>
        .bootstrap-admin-panel-content {
            padding-top: 10px;
        }
        
        .black_overlay {
            display: none;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.3);
            z-index: 1001;
            filter: alpha(opacity=88);
        }
        
        .white_content {
            display: none;
            position: absolute;
            top: 8%;
            left: 25%;
            width: 50%;
            height: auto;
            padding: 20px;
            border: 1px solid gray;
            background-color: white;
            z-index: 1002;
            overflow: auto;
            border-radius: 8px;
        }
        
        .btn-sm {
            margin-left: 20px;
        }
        
        textarea {
            resize: none;
        }
        
        input {
            background-color: white;
        }
    </style>
    <script>
        $(function () {
            $(".add-book").on("click", function () {
                $("#light").hide().fadeIn(600).css("display", "block");
                $("#fade").hide().fadeIn(600).css("display", "block");
            });


            $(".closeBtn").on("click", function () {
                $("#fade").fadeOut(600).hide(300);
                $("#light-import-excel").fadeOut(600).hide(300);
                $("#light-send-email").fadeOut(600).hide(300);
                $("#light-send-SMS").fadeOut(600).hide(300);

            });

            $(".add-readers").on("click", function () {
                $("#light-import-excel").hide().fadeIn(600).css("display", "block");
                $("#fade").hide().fadeIn(600).css("display", "block");
            });

            /*发送邮件按钮注册点击功能*/
            $(".btn-sendEmail").on("click", function () {

                let parent = $(this).parent().parent();


                $("#email-name").val("").val(parent.find(".adminName").text().trim());
                $("#email-email").val("").val(parent.find(".email").text().trim());
                $("#email-message").val("");


                $("#light-send-email").hide().fadeIn(600).css("display", "block");
                $("#fade").hide().fadeIn(600).css("display", "block");
            });
            /*发送手机短信注册点击功能*/
            $(".btn-sendSMS").on("click", function () {

                let parent = $(this).parent().parent();


                $("#SMS-name").val("").val(parent.find(".adminName").text().trim());
                $("#SMS-phone").val("").val(parent.find(".phone").text().trim());
                $("#SMS-message").val("");


                $("#light-send-SMS").hide().fadeIn(600).css("display", "block");
                $("#fade").hide().fadeIn(600).css("display", "block");
            });


        })
    </script>
</head>
<body>
<!--头部-->
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="javascript:;">欢迎来到图书管理系统</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <!--<li><a href="javascript:;" class="btn btn-default btn-login">登录</a></li>-->
                <li class="dropdown" style="margin-top: 5px;">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                       aria-haspopup="true" aria-expanded="false"> <span
                        class="glyphicon glyphicon-user"></span> 欢迎您， admin <span
                        class="caret"></span></a>
                    <ul class="dropdown-menu" style="margin-top: 2px">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<!--主体-->
<div class="container-fluid" id="main">
    <div class="row">
        <div class="col-md-2 left-content">
            <div class="aside-nav">
                <ul class="list-group aside-nav-list">
                    <li class="list-group-item ">
                        <a href="<%=basePath%>/admin/bookmanager/1">图书管理
                            <span class="pull-right glyphicon glyphicon-chevron-right"></span>
                        </a>
                    </li>
                    <li class="list-group-item ">
                        <a href="<%=basePath%>/admin/booktypemanager">图书分类管理
                            <span class="pull-right glyphicon glyphicon-chevron-right"></span>
                        </a>
                    </li>
                    <li class="list-group-item "><a href="javascript:;">图书借阅 <span
                        class="pull-right glyphicon glyphicon-chevron-right"></span></a></li>
                    <li class="list-group-item "><a href="javascript:;">图书归还 <span
                        class="pull-right glyphicon glyphicon-chevron-right"></span></a></li>
                    <li class="list-group-item "><a href="javascript:;">借阅查询 <span
                        class="pull-right glyphicon glyphicon-chevron-right"></span></a></li>
                    <li class="list-group-item "><a href="javascript:;">逾期处理 <span
                        class="pull-right glyphicon glyphicon-chevron-right"></span></a></li>
                    <li class="list-group-item active">
                        <a href="<%=basePath%>/admin/adminmanager">管理员管理
                            <span class="pull-right glyphicon glyphicon-chevron-right"></span>
                        </a>
                    </li>
                    <li class="list-group-item ">
                        <a href="<%=basePath%>/admin/readermanager">读者管理
                            <span class="pull-right glyphicon glyphicon-chevron-right"></span>
                        </a>
                    </li>
                    <li class="list-group-item">
                        <a href="<%=basePath%>/admin/setting">系统设置
                            <span class="pull-right glyphicon glyphicon-chevron-right"></span>
                        </a>
                    </li>
                    <li class="list-group-item "><a href="javascript:;">在线考试 <span
                        class="pull-right glyphicon glyphicon-chevron-right"></span></a></li>
                </ul>
            </div>
        </div>
        <div class="col-md-10 right-content">
            <%--模糊查询的搜索框--%>
            <div class="row">
                <div class="col-md-12">
                    <div class="section-wrap">
                        <div class="wrap-top">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    <h4>查询管理员</h4>
                                </div>
                                <div class="panel-body">
                                    <form class="form-horizontal" method="post"
                                          action="">
                                        <div class="form-group col-md-6">
                                            <label for="adminName"
                                                   class="col-sm-4 control-label text-right">
                                                管理员名字
                                            </label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control"
                                                       id="adminName"
                                                       name="adminName" placeholder="管理员名字">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="adminId"
                                                   class="col-sm-4 control-label text-right">管理员编号
                                            </label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control"
                                                       id="adminId"
                                                       name="adminId" placeholder="管理员编号">
                                            </div>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <button class="btn btn-primary btn-sm "
                                                    style="margin-left: 45px">
                                                查询
                                            </button>
                                            <input type="button"
                                                   class="btn btn-success btn-sm add-admin"
                                                   value="添加" />
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <%--显示表格的div--%>
            <div class="wrap-bottom">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>管理员编号</th>
                        <th>管理员姓名</th>
                        <th>联系电话</th>
                        <th>电子邮箱</th>
                        <th>类别</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <c:if test="${adminlist!=null}">
                        <tbody>
                        <c:forEach items="${adminlist}" var="al">
                            <tr>
                                <td class="adminId">${al.adminId}</td>
                                <td class="adminName">${al.adminName}</td>
                                <td class="phone">
                                        ${al.phone}
                                    <i class="glyphicon glyphicon-phone btn-sendSMS"
                                       style="color: red;"
                                    />
                                </td>
                                <td class="email">
                                        ${al.email}
                                    <i class="glyphicon glyphicon-envelope btn-sendEmail"
                                       style="color: green;" />
                                </td>
                                <td class="state">
                                    <c:if test="${al.state==0}">
                                        <p style="color: darkorange;font-weight: bold;margin: 0">
                                            超级管理员
                                            <span class="glyphicon glyphicon-user"></span>
                                        </p>
                                    </c:if>
                                    <c:if test="${al.state==1}">
                                        普通管理员
                                    </c:if>
                                </td>
                                <td>
                                    <button class="btn btn-xs btn-info btn-watch"
                                            style="margin-right: 3px">查看
                                    </button>
                                    <button class="btn btn-xs btn-warning btn-update"
                                            style="margin-right: 3px">权限
                                    </button>
                                    <button class="btn btn-xs btn-success btn-update"
                                            style="margin-right: 3px">联系
                                    </button>
                                    <c:if test="${al.state==0}">
                                        <a class="btn btn-xs btn-danger disabled"
                                           style="margin-right: 3px">删除
                                        </a>
                                    </c:if>
                                    <c:if test="${al.state==1}">
                                        <a class="btn btn-xs btn-danger btn-del"
                                           style="margin-right: 3px"
                                           href="<%=basePath%>/admin/del/${al.adminId}">删除
                                        </a>
                                    </c:if>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </c:if>
                </table>
            </div>
        </div>
    </div>
</div>
<%--弹出层的半透明背景--%>
<div id="fade" class="modal black_overlay"></div>
<%--导入excel的弹出框--%>
<div id="light-import-excel" class="white_content">
    <button type="button" class="close closeBtn" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <div class="row">
        <div class="col-md-10 col-sm-offset-1">
            <!--保证样式水平不混乱-->
            <form class="form-horizontal" method="post" action="<%=basePath%>/reader/readExcel"
                  enctype="multipart/form-data">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel-import-excel">
                        批量添加读者用户（上传excel）
                    </h4>
                </div>
                <div class="modal-body">
                    <!---------------------表单-------------------->
                    <div class="row">
                        <div class="form-group col-md-12">
                            <label for="import-excel" class="col-md-4 control-label">请选择excel
                                文件</label>
                            <div class="col-md-8">
                                <input type="file" id="import-excel"
                                       name="file" />
                            </div>
                        </div>
                    </div>
                    <!---------------------表单-------------------->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default closeBtn" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="submit" class="btn btn-primary">
                        上传
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<%--发送邮件消息的弹出框--%>
<div id="light-send-email" class="white_content">
    <button type="button" class="close closeBtn" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <div class="row">
        <div class="col-md-10 col-sm-offset-1">
            <!--保证样式水平不混乱-->
            <form class="form-horizontal" method="post" action="<%=basePath%>/admin/sendemail"
                  enctype="multipart/form-data">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel-send-email">
                        发送邮箱消息
                    </h4>
                </div>
                <div class="modal-body">
                    <!---------------------表单-------------------->
                    <div class="row">
                        <div class="form-group col-md-12">
                            <label for="email-name" class="col-md-3 control-label">收件人:</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control disabled" id="email-name"
                                       name="name" readonly />
                            </div>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="email-email" class="col-md-3 control-label">邮件地址:
                            </label>
                            <div class="col-md-9">
                                <input type="text" class="form-control disabled" id="email-email"
                                       name="email" readonly />
                            </div>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="email-message" class="col-md-3 control-label">正文消息:
                            </label>
                            <div class="col-md-9">
                                <textarea class="form-control" rows="8" id="email-message"
                                          name="message" placeholder="请输入消息正文……">
                            </textarea>
                            </div>
                        </div>
                    </div>
                    <!---------------------表单-------------------->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default closeBtn" data-dismiss="modal"
                            title="取消">
                        取消
                    </button>
                    <button type="submit" class="btn btn-primary" title="发送">
                        发送
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<%--发送短信的弹出框--%>
<div id="light-send-SMS" class="white_content">
    <button type="button" class="close closeBtn" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <div class="row">
        <div class="col-md-10 col-sm-offset-1">
            <!--保证样式水平不混乱-->
            <form class="form-horizontal" method="post" action="<%=basePath%>/admin/sendsms"
                  enctype="multipart/form-data">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel-send-SMS">
                        发送手机短信
                    </h4>
                </div>
                <div class="modal-body">
                    <!---------------------表单-------------------->
                    <div class="row">
                        <div class="form-group col-md-12">
                            <label for="SMS-name" class="col-md-3 control-label">收件人:</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control disabled" id="SMS-name"
                                       name="name" readonly />
                            </div>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="email-email" class="col-md-3 control-label">手机号码:
                            </label>
                            <div class="col-md-9">
                                <input type="text" class="form-control disabled" id="SMS-phone"
                                       name="phone" readonly />
                            </div>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="email-message" class="col-md-3 control-label">短信消息:
                            </label>
                            <div class="col-md-9">
                                <textarea class="form-control" rows="8" id="SMS-message"
                                          name="message" placeholder="请输出短信内容">
                            </textarea>
                            </div>
                        </div>
                    </div>
                    <!---------------------表单-------------------->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default closeBtn" data-dismiss="modal"
                            title="取消">
                        取消
                    </button>
                    <button type="submit" class="btn btn-primary" title="发送">
                        发送
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>